
class lbtBig {
    constructor() {
        this.container = $('.img-box')[0]
        this.topL = $('.topL')[0]
        this.topG = $('.topG')[0]
        this.init()

    }
    init() {
        this.request()
        this.time()
    }
    request() {

        pAjax({
            url: '/libs/data/goods.json'
        })
            .then((res) => {
                let LBT = JSON.parse(res)
                LBT = LBT.slice(180, 190)

                this.render(LBT)
                this.xuan(LBT)
            })
    }
    render(LBT) {
        this.container.innerHTML += `
        <img src="${LBT[0].img_big_logo}" class="top-banner">
        `
    }
    xuan(LBT) {
        let j = 0
        this.topL.onclick = function () {
            j--
            if (j < 0) {
                j = 5
            }
            $('.top-banner')[0].src = LBT[j].img_big_logo


        }
        this.topG.onclick = function () {
            j++
            if (j > 5) {
                j = 1
            }
            $('.top-banner')[0].src = LBT[j].img_big_logo
        }
    }
    time(){
        let  timeTopG  = setInterval(() => {
            this.topL.onclick()
        }, 2500);
        
    }

}
new lbtBig()

class lbtMini {
    constructor() {
        this.leftBox = $('.boxleft')[0]
        this.rightBox = $('.rightbox')[0]
        this.buttonL = $('.button-L')[0]
        this.buttonG= $('.button-G')[0]
        this.init()

    }
    init() {
        this.request()
        this.time()
    }
    request() {

        pAjax({
            url: '/libs/data/goods.json'
        })
            .then((res) => {
                let LB = JSON.parse(res)
                LB = LB.slice(200, 220)

                this.render(LB)
                this.XR(LB)
            })
    }
    render(LB) {
        this.leftBox.innerHTML += `
        <img src="${LB[0].img_big_logo}" class="button-banner1">
        `
        this.rightBox.innerHTML += `
        <img src="${LB[10].img_big_logo}" class="button-banner2">
        `
    }
    XR(LB) {
        let j = 0
        let a =0
        let b = 0
        this.buttonL.onclick = function () {
            j--
            if (j < 0) {
                j = 5
            }
            a = Number(j+5)
            b = Number(j+1)
            $('.button-banner1')[0].src = LB[j].img_big_logo
            $('.button-banner2')[0].src = LB[a].img_big_logo
            // $('.page-number')[0].value=b

        }
        this.buttonG.onclick = function () {
            j++
            if (j > 4) {
                j = 0
            }
            a = Number(j+5)
            b = Number(j+1)
            $('.button-banner1')[0].src = LB[j].img_big_logo
            $('.button-banner2')[0].src = LB[a].img_big_logo
            $('.page-number')[0].innerText=b
        }
    }
    time(){
        let  timeTopG  = setInterval(() => {
            this.buttonG.onclick()
        }, 2000);
        
    }

}
new lbtMini()
